﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Reviewer.Entities.Services;
using Reviewer.Business;
using Reviewer.Entities;

/// <summary>
/// Summary description for HelperUtilities
/// </summary>
public static class HelperUtilities
{
    /// <summary>
    /// Gets the name of the format.
    /// </summary>
    /// <param name="formatId">The format id.</param>
    /// <returns></returns>
    public static string GetFormatName(int formatId)
    {
        using (IMetadataService<Format> service = ServiceFactory.GetMetadataService<Format>())
        {
            Format format = service.GetAll().FirstOrDefault(t => t.Id.Equals(formatId));
            if (format != null)
                return format.Name;
            return String.Empty;
        }
    }

    /// <summary>
    /// Gets the name of the news newsType.
    /// </summary>
    /// <param name="newsTypeId">The news newsType id.</param>
    /// <returns></returns>
    public static string GetNewsTypeName(int newsTypeId)
    {
        using (IMetadataService<NewsType> service = ServiceFactory.GetMetadataService<NewsType>())
        {
            NewsType item = service.GetAll().FirstOrDefault(t => t.Id.Equals(newsTypeId));
            if (item != null)
                return item.Name;
            return String.Empty;
        }
    }

    /// <summary>
    /// Gets the name of the multiplayer info.
    /// </summary>
    /// <param name="multiplayerInfoId">The multiplayer info id.</param>
    /// <returns></returns>
    public static string GetMultiplayerInfoName(int multiplayerInfoId)
    {
        using (IMetadataService<MultiplayerInfo> service = ServiceFactory.GetMetadataService<MultiplayerInfo>())
        {
            MultiplayerInfo item = service.GetAll().FirstOrDefault(t => t.Id.Equals(multiplayerInfoId));
            if (item != null)
                return item.Name;
            return String.Empty;
        }
    }
}